package com.jvm.interpreter;

import com.jvm.classfile.model.Instance;

/**
 * @program: diy_simple_jvm
 * @description: Jvm存储数据的基本单位
 * @author: CaoYong
 * @create: 2021-07-08 19:28
 **/
public class Slot {

    // 基础数据类型，存放一个32位的数字
    public int val;

    // 引用数据类型，存放一个对象的引用
    public Instance ref;

    public Slot(int val, Instance ref) {
        this.val = val;
        this.ref = ref;
    }

    public static Slot val(int val) {
        return new Slot(val, null);
    }

    public static Slot ref(Instance ref) {
        return new Slot(0, ref);
    }
}
